package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsClusterDetailConfig;
import com.econ.powercloud.ems.dal.mapper.EmsClusterDetailConfigMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author : zjf
 * @Description : EmsClusterDetailConfig DAO层
 * @Date : 2021/11/3 10:31
 * @Modified by : zjf
 */
@Repository
public class EmsClusterDetailConfigDAO extends ServiceImpl<EmsClusterDetailConfigMapper, EmsClusterDetailConfig> {

    /**
     * 根据类型获取电池pack的分布情况
     */
    public List<EmsClusterDetailConfig> getListByType(Integer type){
        LambdaQueryWrapper<EmsClusterDetailConfig> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(EmsClusterDetailConfig::getType,type);
        return this.baseMapper.selectList(lambdaQueryWrapper);
    }

    public int deleteByType(Integer type){
        LambdaQueryWrapper<EmsClusterDetailConfig> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(EmsClusterDetailConfig::getType,type);
        return this.baseMapper.delete(lambdaQueryWrapper);
    }
}
